from typing import List, Generic

from pydantic import BaseModel, Field

# 单个html的解析
from pydantic.generics import GenericModel

from apps.core.return_info import DataT


class ParseHtmlModel(BaseModel):
    html: str = ""


# 只有makr的model
class MarksModel(BaseModel):
    marks: List[str] = []


# 只有主id和marks的model
class IdMarksModel(BaseModel):
    marks: List[str] = []
    id: str = ''


# 只有id和html的models
class SaveJournalIdModel(BaseModel):
    id: str = ""
    html: str = ""


# 只有id和多个html
class MHtmlModel(BaseModel):
    id: str = ""
    html_list: List[str] = []


# 只有主id
class IdModel(BaseModel):
    id: str = ''


class Paper(GenericModel, Generic[DataT]):
    task_name: str = ''
    id: str = Field("", alias="_id")  # 为task_name+ DataT的内部id
    data: DataT  # 为自己报纸的结构
    update_time: str = ""
    create_time: str = ""


# = '' 当没有默认参数，body就必须有该字段
class InputPlatformModel(GenericModel, Generic[DataT]):
    input_code: str = ''
    input_msg: str = ''
    data: DataT
